// 角色列表(1后台管理员 2院校管理员 3老师 4学生)
export const roleTypes = ['1', '2', '3', '4']

// 角色对应左侧菜单列表
const permission = {
    '1': [
        {
            name: 'schoolManageList',
            meta: {
                title: '学校管理'
            }
        },
        {
            name: 'userManageList',
            meta: {
                title: '用户管理'
            }
        },
        {
            name: 'caseManageList',
            meta: {
                title: '案例管理'
            }
        },
        {
            name: 'testQuestionsList',
            meta: {
                title: '试题管理'
            }
        },
        {
            name: 'policyManageList',
            meta: {
                title: '海关政策'
            }
        },
        {
            name: 'noticeManageList',
            meta: {
                title: '平台公告'
            }
        }
    ],
    '2': [
        {
            name: 'professional',
            meta: {
                title: '专业管理'
            }
        },
        {
            name: 'teaManageList',
            meta: {
                title: '教师管理'
            }
        },
        {
            name: 'classManageList',
            meta: {
                title: '班级管理'
            }
        },
        {
            name: 'caseManageList',
            meta: {
                title: '案例管理'
            }
        },
        {
            name: 'testQuestionsList',
            meta: {
                title: '试题管理'
            }
        },
        {
            name: 'examManageList',
            meta: {
                title: '考试管理'
            },
            children: [
                {
                    name: 'examManageList',
                    meta: {
                        title: '考试管理'
                    }
                },
                {
                    name: 'testPaperList',
                    meta: {
                        title: '试卷管理'
                    }
                }
            ]
        },
        {
            name: 'trainingList',
            meta: {
                title: '实训管理'
            }
        },
        {
            name: 'scoreList',
            meta: {
                title: '成绩管理'
            },
            children: [
                {
                    name: 'scoreList',
                    meta: {
                        title: '成绩管理'
                    }
                },
                {
                    name: 'practiceStatistics',
                    meta: {
                        title: '练习统计'
                    }
                }
            ]
        },
        {
            name: 'topicList',
            meta: {
                title: '话题讨论'
            }
        }
    ],
    '3': [
        {
            name: 'classManageList',
            meta: {
                title: '班级管理'
            }
        },
        {
            name: 'trainingList',
            meta: {
                title: '实训管理'
            }
        }
    ],
    '4': {
        default: [
            {
                name: 'examgradelist',
                meta: {
                    title: '成绩详情'
                }
            },
            {
                name: 'traingradelist',
                meta: {
                    title: '实训详情'
                }
            }
        ],
        training: [
            {
                name: 'basicManage',
                meta: {
                    title: '基础数据'
                },
                children: [
                    {
                        name: 'parameter',
                        meta: {
                            title: '通关参数'
                        }
                    },
                    {
                        name: 'customerList',
                        meta: {
                            title: '客户管理'
                        }
                    },
                    {
                        name: 'electronic',
                        meta: {
                            title: '电子委托'
                        }
                    }
                ]
            },
            {
                name: 'customManage',
                meta: {
                    title: '通关管理'
                },
                children: [
                    {
                        name: 'declareJK',
                        meta: {
                            title: '进口报关'
                        }
                    },
                    {
                        name: 'declareCK',
                        meta: {
                            title: '出口报关'
                        }
                    },
                    {
                        name: 'declareJJ',
                        meta: {
                            title: '进境报关'
                        }
                    },
                    {
                        name: 'declareCJ',
                        meta: {
                            title: '出境报关'
                        }
                    },
                    {
                        name: 'invtList',
                        meta: {
                            title: '核注清单'
                        }
                    },
                    {
                        name: 'reliefsList',
                        meta: {
                            title: '减免税'
                        }
                    },
                    {
                        name: 'declareIM',
                        meta: {
                            title: '进口转关提前报关整合申报'
                        }
                    },
                    {
                        name: 'declareEX',
                        meta: {
                            title: '出口转关提前报关整合申报'
                        }
                    }
                ]
            },
            {
                name: 'trade',
                meta: {
                    title: '加工贸易'
                },
                children: [
                    {
                        name: 'tradeList',
                        meta: {
                            title: '加贸手册'
                        }
                    },
                    {
                        name: 'tradeCheckList',
                        meta: {
                            title: '加贸手册报核'
                        }
                    }
                ]
            },
            {
                name: 'manifest',
                meta: {
                    title: '舱单管理'
                },
                children: [
                    {
                        name: 'rmftList',
                        meta: {
                            title: '公路舱单'
                        }
                    },
                    {
                        name: 'smftList',
                        meta: {
                            title: '海运舱单'
                        }
                    }
                ]
            },
            {
                name: 'certificate',
                meta: {
                    title: '海关原产地证申报'
                },
                children: [
                    {
                        name: 'certAdd',
                        meta: {
                            title: '原产地申请'
                        }
                    },
                    {
                        name: 'certList',
                        meta: {
                            title: '证书列表'
                        }
                    }

                ]
            },
            {
                name: 'licence',
                meta: {
                    title: '许可证申请'
                },
                children: [
                    {
                        name: 'licenceExport',
                        meta: {
                            title: '出口许可证'
                        }
                    },
                    {
                        name: 'licenceProduct',
                        meta: {
                            title: '机电产品进口许可证'
                        }
                    },
                    {
                        name: 'licenceNoProduct',
                        meta: {
                            title: '非机电产品进口许可证'
                        }
                    }, {
                        name: 'licenceFarm',
                        meta: {
                            title: '农药进出口登记管理'
                        }
                    }

                ]
            },
            {
                name: 'taxManager',
                meta: {
                    title: '税费办理'
                },
                children: [
                    {
                        name: 'taxList',
                        meta: {
                            title: '税费单查询'
                        }
                    },
                    {
                        name: 'taxHistory',
                        meta: {
                            title: '交易历史查询'
                        }
                    }

                ]
            }
        ]
    }
}

export function resolveTypeByPath (path) {
    const v = path.split('/')[1]
    return v || 'default'
}

export function getPermission (role, type) {
    const per = permission[role]
    if (Object.prototype.toString.call(per) === '[object Object]') {
        type = type || resolveTypeByPath(decodeURI(window.location.pathname))
        return per[type] || per.default || []
    }
    return per || []
}
